const STORAGE_KEY = 'on-boarding-checklist'

// import qs from 'qs'
export default {
  get() {
    return JSON.parse(window.localStorage.getItem(STORAGE_KEY) || '[]')
  },
  del() {
    window.localStorage.removeItem(STORAGE_KEY)
  },
  set(items) {
    window.localStorage.setItem(STORAGE_KEY, JSON.stringify(items))
  },
  getkey(key) {
    const item = window.localStorage.getItem(key)
    if (this.isNull(item)) {
      return ''
    }
    const value = JSON.parse(item)
    return value
  },
  setkey(key, items) {
    const value = JSON.stringify(items)
    window.localStorage.setItem(key, value)
  },
  /**
   * 判断是否为空
   */
  isNull(val) {
    if (val instanceof Array) {
      if (val.length === 0) return true
    } else if (val instanceof Object) {
      const arr = Object.keys(val) // 判断对象是否为空
      if (arr.length <= 0) return true
    } else {
      const str = '' + val
      if (str === '[]' || str === '{}') {
        return true
      } else if (val === 'null' || val == null || val === 'undefined' || val === undefined || val === '') return true
      return false
    }
    return false
  }
}
